const exp=require('express')
const router=exp.Router()
const newsMdel=require('../db/model/newsModel')


router.post('/addnews',(req,res)=>{
  newsMdel.create(req.body,(err,data)=>{
    res.redirect('/list')
  })
})

router.post('/update',(req,res)=>{
  let {title,content,id} = req.body;
  newsMdel.updateOne({_id:id},{title,content},(err,data)=>{
    res.redirect('/list')
  })
})

module.exports=router